﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace WindowsGame1
{
    public class Coordinate
    {
        public static int selectedX, selectedY;

        public static void AccurateCoordinate(int StateX, int StateY)
        {
            int localX = StateX % 40;
            int localY = StateY % 60;
            selectedX = StateX / 40;
            selectedY = StateY / 60 * 2;
            if (localX <= 20)
            {
                if (localY - 0 <= -0.5 * localX + 10)
                {
                    selectedX += -1;
                    selectedY += -1;
                }
                else if (localY - 10 <= 0 * localX + 20)
                {
                    selectedX += 0;
                    selectedY += 0;
                }
                else if (localY - 30 <= 0.5 * localX + 0)
                {
                    selectedX += 0;
                    selectedY += 0;
                }
                else
                {
                    selectedX += -1;
                    selectedY += 1;
                }
            }
            else
            {
                if (localY - 0 <= 0.5 * (localX - 20) + 0)
                {
                    selectedX += 0;
                    selectedY += -1;
                }
                else if (localY - 10 <= 0 * (localX - 20) + 20)
                {
                    selectedX += 0;
                    selectedY += 0;
                }
                else if (localY - 30 <= -0.5 * (localX - 20) + 10)
                {
                    selectedX += 0;
                    selectedY += 0;
                }
                else 
                {
                    selectedX += 0;
                    selectedY += 1;
                }
            }

        }
    }
}
